package com.mycompany.project.client;

import com.google.gwt.event.shared.GwtEvent;

/**
 *  @author Laboratorio Tv Collaborativa/Contenuti Digitali --> Sardegna District --> Crs4 --> Sardegna Ricerche
 *  
 *  This class extends a GwtEvent class and implements @SaStria AnnotationSave event and in particular mode the 
 *  fire the onAnnotationSaved event. This onAnnotationSaved event should be fired when a user execute double click
 *  an annotation tag on video player by @SaStria tools interface. This class is responsible for handle and
 *  dispatch the onAnnotationMoved event.  
 */
public class AnnotationSaveEvent extends GwtEvent<AnnotationSaveEventHandler> {
	public static Type<AnnotationSaveEventHandler> TYPE=new Type<AnnotationSaveEventHandler>();
	private double annotationTimeEnd;    // annotation video segment end time. 
	private double annotationTimeStart;  // annotation video segment start time.
	int annotationPreviewIndex; // index of annotation in previews panel list.
	
	
	
	/**
	 * Constructor
	 */
	public AnnotationSaveEvent(double timeS, double timeE, int previewIndex ) {
		annotationTimeStart=timeS;
		annotationTimeEnd=timeE;
		annotationPreviewIndex=previewIndex;
	}
	
	
	
	/**
	 * This method return the system parameter TYPE. Type class is used to register events with the HandlerManager.
	 * Type is parameterized by the handler type in order to make the addHandler method type safe.
	 *  Gets the type associated with this event.
	 */
	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<AnnotationSaveEventHandler> getAssociatedType() {
		// TODO Auto-generated method stub
		return TYPE;
	}
	
	
	
	/**
	 * This method run and dispatch the onAnnotationMoved event.
	 * Should only be called by HandlerManager.
	 * @param handler: handler of AnnotationSaveEventHandler. 
	 */
	@Override
	protected void dispatch(AnnotationSaveEventHandler handler) {
		handler.onAnnotationSaved(this);		
	}
	
	/**
	 * Sets annotation video segment end time.
	 * @param timeValue double value indicating annotation video segment end time.
	 */
	public void setTimeEnd(double timeValue){
		annotationTimeEnd=timeValue;
	}
	
	/**
	 * Gets annotation video segment Start time.
	 * @return timeValue double value indicating annotation video segment start time.
	 * 
	 */
	public double getTimeStart(){
		return(annotationTimeStart);
	}
	
	/**
	 * Gets annotation video segment end time.
	 * @return timeValue double value indicating annotation video segment end time.
	 */
	public double getTimeEnd(){
		return(annotationTimeEnd);
	}
	/**
	 * Sets annotation video segment start time.
	 * @param timeValue double value indicating annotation video segment end time.
	 */
	public void setTimeStart(double timeValue){
		annotationTimeStart=timeValue;
	}
	
	/**
	 * Sets annotation video segment start and end time.
	 * @param timeValueStart
	 * @param timeValueEnd
	 */
	public void setTimesegment(double timeValueStart,double timeValueEnd){
		setTimeStart(timeValueStart);
		setTimeEnd(timeValueEnd);
	}

	
	/**
	 * Gets annotation index in previews panel list.
	 * @return
	 */
	public int getAnnotationPreviewIndex(){
		return(annotationPreviewIndex);
	}
}
